﻿/**
 *	\file		lxpref_route_clt_usr.hxx
 *	\date		(2014-12-17 22:59:39)/(2014-12-17 22:59:39)
 *-----------------------------------------------------------------------------
 *	\brief
 *	\version	1.0.0.1
 *	\author		Nick Shallery	(nicknide@gmail.com)
 *	\copyright	YOU HAVE ALL LEFT WITH THIS CODE WHILE YOU KEEP COMMENT IN EVERY COPY.
 *-----------------------------------------------------------------------------
**/

#if			!defined(__LOLIX__LOLIX_TYPE__K_IN_G__)
#	include	<lolix/lolix_type.h>
#endif	//	!defined(__LOLIX__LOLIX_TYPE__K_IN_G__)

#if			!defined(__LOLIX__TOY__STD_VECTOR__NICK__K_IN_G__)
#	include	<lolix/toy/std_vector.hpp>
#endif	//	!defined(__LOLIX__TOY__STD_VECTOR__NICK__K_IN_G__)


namespace lolix{namespace loli{class file_async;}}
namespace lolix{namespace toy{class stdc_fun;}}
namespace lxpref{namespace message{enum PREF_MSG_TYPE LOLIX_ETYPE(lolix::lx_u32);}}
namespace lxsamsara{class recurrence;}

namespace lxpref{namespace _inst{
	class clt_usr
		: public lolix::itf_Tbase<clt_usr, lolix::itf>
	{
		LOLIX_DEFINE_ITF(lxpref::_inst::clt_usr, lolix::itf, (0x0b4515ca, 0xcb6b40e2, 0xa36fd78f, 0x54f13c97));
		typedef lolix::toy::vector<lolix::lx_u8, allocator_type> _TDataType;
		lolix::dynamic_allocator*	_alc;
		lolix::loli::file_async*	_fasync;
		lolix::toy::stdc_fun*		_stdc;
		lxsamsara::recurrence*		_recur;
		lolix::size_type			_dat_cnt;
		_TDataType					_net_dat;
		clt_usr(lolix::dynamic_allocator* alc);
		~clt_usr(void);
	public:
		typedef void (LOLIX_CALL *Fn_OnRecvMsg)(clt_usr* cusr, message::PREF_MSG_TYPE msgType, void const* buf, lolix::size_type buf_size, void* usr_ptr);
		static LOLIX_RETNV LOLIX_CALL create_inst(this_type** out_ptr
			, lolix::dynamic_allocator* alc
			, lolix::ref_factory* ref_fac
			, lolix::toy::stdc_fun* stdc
			, lolix::loli::file_async* fasync
			, lxsamsara::recurrence* recur
			);
		lolix::loli::file_async* _get_file_async(void)const;
		void _get_recv_buf(void** out_buf, lolix::size_type* buf_size);
		void _do_recv(lolix::size_type datLen, Fn_OnRecvMsg onRecvMsg, void* usr_ptr);
	};
}}
